<?php



namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * @OA\Schema(
 *     schema="Issue",
 *     type="object",
 *     @OA\Property(property="id", type="integer", example=6),
 *     @OA\Property(property="title", type="string", example="title 002"),
 *     @OA\Property(property="description", type="string", example="description 002"),
 *     @OA\Property(property="user_id", type="integer", example=7),
 *     @OA\Property(property="assigned_to", type="integer", nullable=true, example=null),
 *     @OA\Property(property="created_at", type="string", format="date-time", example="2025-03-08T10:48:37.000000Z"),
 *     @OA\Property(property="updated_at", type="string", format="date-time", example="2025-03-08T10:48:37.000000Z"),
 * )
 */
class Issue extends Model
{
    protected $fillable = ['title', 'description', 'user_id', 'assigned_to'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function assignedTo()
    {
        return $this->belongsTo(User::class, 'assigned_to');
    }

    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}
